package com.orchidea.uml.model.document
{
import com.orchidea.uml.model.*;
    import flash.utils.Dictionary;

    public class DocumentFactory
    {
        private static var _factoryMap : Dictionary;


		private function get factoryMap( ) : Dictionary {
			if ( _factoryMap == null ) {
				_factoryMap = new Dictionary();
				_factoryMap[DocumentType.CLASS] = Document;
			}

			return _factoryMap;
		}

        /**
		 * Create a new document of the specified type using some default data.
		 *
		 * @throws an exception if this factory cannot create documents of the specified type.
         *
		 */
		public function createDocument( type : DocumentType ) : Document {
			if ( factoryMap[type] == null )
            {
				throw new ArgumentError("Cannot create document, unknown type: \"" + type + "\"");
			}

			var documentClass : Class = factoryMap[type];

			var document : Document = new documentClass(type);

//			if ( data != null )
//            {
//				document.setTitle(data.title);
//				document.setText(data.text);
//			}

			return document;
		}

    }
}